using System;
using Framework;
using UnityEngine;
using UnityEngine.UI;

namespace GameCore.UI
{
    public class PanelAdventureMenu : MonoBehaviour
    {
        public Button btn_ShowMenu;
        public Button btn_ResumeGame;
        public Button btn_ForceEvacuate;
        public Button btn_Settings;
        public Button btn_SaveAndQuit;

        private void Start()
        {
            btn_ShowMenu.onClick.AddListener(Show);
            btn_ResumeGame.onClick.AddListener(Hide);
            btn_Settings.interactable = false;
            if (btn_ForceEvacuate)
            {
                btn_ForceEvacuate.onClick.AddListener(() =>
                {
                    var adventure = LevelManager.GetCurrentAdventure();
                    if (adventure != null) adventure.ForceEvacuate();
                });
            }
            btn_SaveAndQuit.onClick.AddListener(() =>
            {
                LevelManager.Save();
                GameManager.LoadScene("MainMenu");
            });
            Hide();
        }

        public void Show()
        {
            PlayerInputHandler.Block(this);
            gameObject.SetActive(true);
        }

        public void Hide()
        {
            PlayerInputHandler.Unblock(this);
            gameObject.SetActive(false);
        }
    }
}